#!/bin/sh
# MetaCard 2.4 stack
# The following is not ASCII text,
# so now would be a good time to q out of more
exec mc $0 "$@"
                                                                                                                                 n Untitled 2  P        ^ <%3                     U Helvetica Neue   U Helvetica Neue,unicode  cRevStandaloneSettings    %cursors  falseWindows,productversion1  1
askDialog  trueOSX,copyright  #2015  All rights reserved worldwideWindows,ProductName  
Untitled 2Windows,productversion3  0scriptLibraries  Internet
Geometry
PrintingUNIX,fileSelector  trueOSX,identifier  com..untitled2Windows,fileversion4  0inclusions  searchWindows,documenticonFile  /Users/Cyclone/Applications/LiveCode Community 8.0 (dp 2).app/Contents/Tools/Runtime/Windows/x86-32/Support/Sample Icons/genericdoc.icoOSX,shortVersion  1.0.0.0OSX,documentExtension   name  
Untitled 2	OSX,name  
Untitled 2MacOSX x86-32  trueWindows,fileversion2  0Windows  trueLinux  trueWindows,FileDescription  Untitled 2 1.0.0.0 for WindowsWindows,productversion2  0UNIX,pageSetup  trueOSX,signature  ????	OSX,info  Untitled 2 Version 1.0.0.0Windows,productversion4  0Windows,companyname   Windows,fileversion1  1OSX,documentType   Windows,fileversion3  0UNIX,colorChooser  trueUNIX,printerChooser  true
answerDialog  trueWindows,iconFile  /Users/Cyclone/Applications/LiveCode Community 8.0 (dp 2).app/Contents/Tools/Runtime/Windows/x86-32/Support/Sample Icons/genericapp.icodefaultBuildFolder  /Users/Cyclone/DesktopWindows,LegalCopyright  #2015  All rights reserved worldwideOSX,longVersion  Untitled 2 1.0.0.0 cREVGeometryCache    stackID  1134 cREVGeneral    breakpoints   breakpointstates   scripteditorselection  0breakpointconditions   scripteditorvscroll  0stackfileversion  7.0scalefactor  1      	Pon preOpenCard
   set the grid to true
   set the gridSize to 20
   
   set the blendLevel of field "Measure Lines" to 10
   set the blendLevel of graphic "Sheet Music Interface" to 90
   
   set the cantSelect of field "Sheet Music Display" to false
   set the cantSelect of field "Measure Lines" to false
   set the cantSelect of graphic "Sheet Music Interface" to false
end preOpenCard
          %3     cREVGeneral    scripteditorvscroll  0scripteditorselection  155 cREVGeometryCacheIDs    1440552601110  10181440858486295  11341440613558171  10241440552307591  10171440550852445  10071440552104772  10131440691176503  11151440550852447  10091440613558172  10251440552124741  10141440801035830  11291440551660624  10121440623458775  10751440687309172  10781440623447528  10741440551369802  1011 cREVGeometrycache    total  16order  
                     2  3  6  [  i  n  
   Measure Lines )k             basicTableObject  truemaxEditableColumns  10cellFormatting  false                      @ cREVGeneral    scripteditorvscroll  0scripteditorselection  0revUniqueID  
1440550852445    
'       
   Sheet Music Display )k             basicTableObject  truemaxEditableColumns  10cellFormatting  false                       P cREVGeneral    scripteditorvscroll  0scripteditorselection  0revUniqueID  
1440551369802    
'       
   Debug  )h        W Q d                        cREVGeneral    revUniqueID  
1440551660624    
'       
   Note Location Data  )h        0                         cREVGeneral    revUniqueID  
1440552104772    , 4 , 2 5 , 4 1 , 2 , 1 , 1 4 
'        2 , 8 , 2 , 8 
'        
'       
   lbl Note Location Data M         n                        cREVGeneral    revUniqueID  
1440552124741     ) N o t e   L o c a t i o n   D a t a   : 
'      (   Debug p/*
on mouseUp
   lock screen
   
   put the bottom of grc "Rectangle" - (the height of grc "Rectangle" / 2) + 4 into n.B
   put the top of grc "Rectangle" + (the height of grc "Rectangle" / 2) - 4 into n.T
   put the right of grc "Rectangle" into n.R
   put the right of grc "Rectangle" - 8 into n.L
   
   set the height of grc "test" to abs(n.B - n.T)
   set the width of grc "test" to abs(n.R - n.L)
   set the top of grc "test" to n.T
   set the bottom of grc "test" to n.B
   set the left of grc "test" to n.L
   set the right of grc "test" to n.R
   
   set the layer of me to -1
   
   unlock screen
end mouseUp
*/


on mouseUp
   
   set the tabStops of field "Sheet Music Row Names" to 50
   
end mouseUp
     @ W < R                                       cREVGeneral    scripteditorvscroll  0scripteditorselection  586revUniqueID  
1440550852447	     
    Note Count  +h        X (                        cREVGeneral    revUniqueID  
1440613558171    2 
'      
   lbl Note Count M         P                        cREVGeneral    revUniqueID  
1440613558172      N o t e   C o u n t   : 
'         Sheet Music Interface  KPon mouseDown theButton
   
   if theButton is 3 then
      send createNote to me
      put moveNote() into xyCoor
      dispatch dataNote with xyCoor
   end if
   
end mouseDown


on dataNote xyCoor
   lock screen
   --put line ((item 2 of xyCoor) + 1) of field "Sheet Music Row Names" into field "Debug"
   put field "Note Count" into noteNum
   put word 1 to -1 of item 1 of xyCoor * 2 into xCoor
   put word 1 to -1 of item 2 of xyCoor - 1 into yCoor
   put the width of grc ("Note" && field "Note Count") / 20 into theWidth
   put noteNum & "," & xCoor & "," & yCoor & "," & theWidth & cr after field "Note Location Data"
   unlock screen
end dataNote


function moveNote
   lock screen
   
   put 0 into wCounter
   repeat until wCounter * the width of grc "Note 0" >=  item 1 of the mouseLoc - the left of me
      add 1 to wCounter
   end repeat
   put the left of me + (wCounter * the width of grc "Note 0") into xCor
   
   put 0 into hCounter
   repeat until hCounter * the height of grc "Note 0" >= item 2 of the mouseLoc - the top of me
      add 1 to hCounter
   end repeat
   put the top of me + (hCounter * the height of grc "Note 0") into yCor
   
   set the loc of grc ("Note" && field "Note Count") to xCor - (the width of grc "Note 0" / 2), yCor - (the height of grc "Note 0" / 2)
   
   return wCounter, hCounter
   
   unlock screen
end moveNote


on createNote
   lock screen
   add 1 to field "Note Count"
   copy grc "Note 0"
   paste
   set the name of grc "Note 0" to ("Note" && field "Note Count")
   unlock screen
end createNote

                 cREVGeneral    revUniqueID  
1440552601110scripteditorvscroll  0scripteditorselection  915  2 
Scrollbar  ia           focusBorder       1  100        cREVGeneral    revUniqueID  
1440623447528  3 
Scrollbar   i`          focusBorder           cREVGeneral    revUniqueID  
1440623458775
  6 Sheet Music Row Names )k              basicTableObject  truemaxEditableColumns  10cellFormatting  false                       2 cREVGeneral    scripteditorvscroll  0scripteditorselection  0revUniqueID  
1440687309172        
'          C 4 
'          B 3 
'          A 3 
'          G 3 
'          F 3 
'          E 3 
'          D 3 
'          C 2 
'          B 2 
'          A 2 
'          G 2 
'          F 2 
'          E 2 
'          D 2 
'          C 2 
'      
  [ Field  )h                                 cREVGeneral    revUniqueID  
1440691176503    # , C , R , W 
'        i Note 2  KPon mouseDown theButton
   
   if theButton is 3 
   then delete me 
   else pass mouseDown
   
end mouseDown


on mouseEnter
   choose pointer tool
   select me
end mouseEnter


on mouseMove
   lock screen

   set the layer of grc "Playhead" to -1
   
   if mouse(1) is up then
      
      put the bottom of me - (the height of me / 2) - 3 into rB
      put the top of me + (the height of me / 2) + 3 into rT
      put the right of me into rR
      put the right of me - 6 into rL
      
      put the bottom of me - (the height of me / 2) - 3 into lB
      put the top of me + (the height of me / 2) + 3 into lT
      put the left of me into lL
      put the left of me + 6 into lR
      
      -- 1st is left, 2nd is bottom, 3rd is right, 4th is top
      
      switch
         case the mouseLoc is within rL,rB,rR,rT
         case the mouseLoc is within lL,lB,lR,lT
            set the lineSize of me to 2
            break
         default 
            set the lineSize of me to 1
      end switch
      
   else if mouse(1) is down then
      
      put the height of grc "Note 0" into xInc
      put the width of grc "Note 0" / 4 into yInc
      put char 7 to -2 of word 2 of the name of me into noteNum
      put line noteNum of field "Note Location Data" into f.Data
      
      -- Item 4
      if the width of me is not item 4 of f.Data * yInc 
      then put the width of me / yInc into item 4 of f.Data
      
      -- Item 2
      if the left of me is not the left of grc "Sheet Music Interface" + (item 2 of f.Data * yInc)
      then put (the left of me - the left of grc "Sheet Music Interface") / yInc into item 2 of f.Data
      
      -- Item 3
      if the top of me is not the top of grc "Sheet Music Interface" + (item 3 of f.Data * xInc)
      then put (the top of me - the top of grc "Sheet Music Interface") / xInc into item 3 of f.Data
      
      // fix top move
      if the top of me < the top of grc "Sheet Music Interface"
      then set the top of me to the top of grc "Sheet Music Interface"
      
      // fix left move
      if the left of me < the left of grc "Sheet Music Interface"
      then set the left of me to the left of grc "Sheet Music Interface"
      
      // fix right move
      if the right of me > the right of grc "Sheet Music Interface"
      then set the right of me to the right of grc "Sheet Music Interface"
      
      // fix bottom move
      if the bottom of me > the bottom of grc "Sheet Music Interface"
      then set the bottom of me to the bottom of grc "Sheet Music Interface"
      
      /*
      if item 1 of the mouseLoc - item 1 of the loc of me > 20
      then 
         */
         
         // allow move again only if mouse if nearby
         
         put f.Data into line noteNum of field "Note Location Data"
         
      end if
      
      unlock screen
end mouseMove


on mouseRelease
   select empty
   choose browser tool
end mouseRelease


on mouseLeave
   set the lineSize of me to 1
   if mouse(1) is up then
      select empty
      choose browser tool
   end if
end mouseLeave
                 cREVGeneral    revUniqueID  
1440801035830scripteditorselection  2555debugParameters   debugEntryHandler  M,mouseDownscripteditorvscroll  879  n Note 0  KPon mouseDown theButton
   
   if theButton is 3 
   then delete me 
   else pass mouseDown
   
end mouseDown


on mouseEnter
   choose pointer tool
   select me
end mouseEnter


on mouseMove
   lock screen

   set the layer of grc "Playhead" to -1
   
   if mouse(1) is up then
      
      put the bottom of me - (the height of me / 2) - 3 into rB
      put the top of me + (the height of me / 2) + 3 into rT
      put the right of me into rR
      put the right of me - 6 into rL
      
      put the bottom of me - (the height of me / 2) - 3 into lB
      put the top of me + (the height of me / 2) + 3 into lT
      put the left of me into lL
      put the left of me + 6 into lR
      
      -- 1st is left, 2nd is bottom, 3rd is right, 4th is top
      
      switch
         case the mouseLoc is within rL,rB,rR,rT
         case the mouseLoc is within lL,lB,lR,lT
            set the lineSize of me to 2
            break
         default 
            set the lineSize of me to 1
      end switch
      
   else if mouse(1) is down then
      
      put the height of grc "Note 0" into xInc
      put the width of grc "Note 0" / 4 into yInc
      put char 7 to -2 of word 2 of the name of me into noteNum
      put line noteNum of field "Note Location Data" into f.Data
      
      -- Item 4
      if the width of me is not item 4 of f.Data * yInc 
      then put the width of me / yInc into item 4 of f.Data
      
      -- Item 2
      if the left of me is not the left of grc "Sheet Music Interface" + (item 2 of f.Data * yInc)
      then put (the left of me - the left of grc "Sheet Music Interface") / yInc into item 2 of f.Data
      
      -- Item 3
      if the top of me is not the top of grc "Sheet Music Interface" + (item 3 of f.Data * xInc)
      then put (the top of me - the top of grc "Sheet Music Interface") / xInc into item 3 of f.Data
      
      // fix top move
      if the top of me < the top of grc "Sheet Music Interface"
      then set the top of me to the top of grc "Sheet Music Interface"
      
      // fix left move
      if the left of me < the left of grc "Sheet Music Interface"
      then set the left of me to the left of grc "Sheet Music Interface"
      
      // fix right move
      if the right of me > the right of grc "Sheet Music Interface"
      then set the right of me to the right of grc "Sheet Music Interface"
      
      // fix bottom move
      if the bottom of me > the bottom of grc "Sheet Music Interface"
      then set the bottom of me to the bottom of grc "Sheet Music Interface"
      
      /*
      if item 1 of the mouseLoc - item 1 of the loc of me > 20
      then 
         */
         
         // allow move again only if mouse if nearby
         
         put f.Data into line noteNum of field "Note Location Data"
         
      end if
      
      unlock screen
end mouseMove


on mouseRelease
   select empty
   choose browser tool
end mouseRelease


on mouseLeave
   set the lineSize of me to 1
   if mouse(1) is up then
      select empty
      choose browser tool
   end if
end mouseLeave
       d P         cREVGeneral    revUniqueID  
1440858486295scripteditorselection  2555debugParameters   debugEntryHandler  M,mouseDownscripteditorvscroll  879   	Playhead  K        	             cREVGeneral    revUniqueID  
1440552307591 